//
//  U9TaskManager.m
//  U9WatchGame
//
//  Created by uuu9 on 2017/3/30.
//  Copyright © 2017年 Jason. All rights reserved.
//

#import "U9TaskManager.h"
#import "DailyTask.h"
#import "U9UserDailyTaskModel.h"
#import "U9PointHistroyListModel.h"


@implementation U9TaskManager

+ (void)commitTaskWithType:(NSInteger)type andUID:(NSString *)uid andCompletionHandle:(void(^)(DailyTask *model, NSError *error))complete
{
    NSString *param = [NSString stringWithFormat:@"userid=%@&task=%li",uid,(long)type];
    [self POSTBase64:[NSString stringWithFormat:@"%@%@",Api_URL,kCommitTask]
    parameters:param
completionHandler:^(id responseObj, NSError *error) {
    DailyTask *task = [DailyTask mj_objectWithKeyValues:responseObj];
    if (task.error_code != 0) {
        error = [self createError:task.error_msg];
    }
    complete(task,error);
}];
}


+ (void)getUserDailyTaskWithUserid:(NSString *)uid andCompletionHandle:(void(^)(U9UserDailyTaskModel *model, NSError *error))complete
{
    NSString *param = [NSString stringWithFormat:@"userid=%@",uid];
  
    [self POSTBase64:[NSString stringWithFormat:@"%@%@",Api_URL,kGetUserDailyTask]
    parameters:param
completionHandler:^(id responseObj, NSError *error) {
        U9UserDailyTaskModel *model = [U9UserDailyTaskModel mj_objectWithKeyValues:responseObj];
        if (model.error_code != 0) {
            error = [self createError:model.error_msg];
        }
        complete(model,error);
    }];
}




+ (void)getPointHistoryListWithUserid:(NSString *)uid andLastid:(NSString *)lastid andCompletionHandle:(void(^)(U9PointHistroyListModel *model, NSError *error))complete
{
    NSString *param = [NSString stringWithFormat:@"userid=%@&lastid=%@",uid,lastid];
    [self POSTBase64:[NSString stringWithFormat:@"%@%@",Api_URL,kGetUserTaskHistory]
          parameters:param
   completionHandler:^(id responseObj, NSError *error) {
       U9PointHistroyListModel *model = [U9PointHistroyListModel mj_objectWithKeyValues:responseObj];
       if (model.error_code != 0) {
           error = [self createError:model.error_msg];
       }
       complete(model,error);
   }];
}


@end
